scrolledwindow: improve v/hscrollbar proximity detection
authorCarlos Garnacho <carlosg@gnome.org>
Mon, 1 Dec 2014 12:59:22 +0000 (13:59 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 24 Dec 2014 14:26:43 +0000 (09:26 -0500)
Only horizontal coordinates are checked for the vertical scrollbar, and
vice versa.

gtk/gtkscrolledwindow.c

index 774b59bc2e2a933e54ee107820f9edb4cb2405f4..f08b04c93f406a8c46a10b49dd348a2c560fb8c8 100644 (file)
@@ -954,10 +954,12 @@ event_close_to_indicator (GtkScrolledWindow *sw,
                           GdkEvent          *event)
 {
   GtkAllocation alloc, indicator_alloc;
+  GtkScrolledWindowPrivate *priv;
   GtkWidget *event_widget;
   gint win_x, win_y;
   gdouble x, y;
 
+  priv = sw->priv;
   event_widget = gtk_get_event_widget (event);
   gdk_event_get_coords (event, &x, &y);
 
@@ -978,14 +980,12 @@ event_close_to_indicator (GtkScrolledWindow *sw,
       y = ycoord;
     }
 
-  if (x < 0 || x > alloc.width ||
-      y < 0 || y > alloc.height)
-    return FALSE;
-
-  if (x > win_x - 50 &&
-      x < win_x + indicator_alloc.width + 50 &&
-      y > win_y - 50 &&
-      y < win_y + indicator_alloc.height + 50)
+  if ((indicator == &priv->hindicator &&
+       y >= win_y - 50 &&
+       y < win_y + indicator_alloc.height + 50) ||
+      (indicator == &priv->vindicator &&
+       x >= win_x - 50 &&
+       x < win_x + indicator_alloc.width + 50))
     return TRUE;
 
   return FALSE;